package gui;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.SwingUtilities;

import mediator.Mediator;

public class MouseApp extends MouseAdapter {
	Mediator med;

	public MouseApp(Mediator md) {
		super();
		med = md;
	}

	public void mousePressed(MouseEvent e) {
		med.mainWindow.notificationsTxt.setText("");
		med.mainWindow.table.getSelectionModel().setSelectionInterval(med.mainWindow.table.rowAtPoint(new Point(e.getX(), e.getY())), med.mainWindow.table.rowAtPoint(new Point(e.getX(), e.getY())));
	}

	public void mouseReleased(MouseEvent e) {
		if(SwingUtilities.isRightMouseButton(e)){
			
			int x = med.mainWindow.table.rowAtPoint(new Point(e.getX(), e.getY()));
			if (x != -1) {
				med.mouseRightClick(e.getX(), e.getY());

				// Set selected Row
				med.selectedRow = x;
			}
		}
	}
}
